<!doctype html>
<html>
{include file="head.html"}
 
<body>
  <div class="fullscreen">
        <div class="scroll_content">
            <div class="topfixed">
                <div class="t_left"><a href="/index.php?m=sushe&a=my"><i class="back"></i></a></div>
                <div class="t_main">我的寝室</div>

            </div>
            <div class="paddingheight"></div>
            <form method="post" id="sushe-form">
            <input type="hidden" name="id" value="{$data.id}">
            <div class="comblock">
          	  
                <div class="my_bedroom_tianjia">
                    <select id="site_city_1" >
                        <option value="0">区域</option>
                        {foreach item=c from=$sclist}
                        <option value="{$c.sc_id}" {if $c.sc_id eq $site_city.pid} selected{/if}>{$c.title}</option>
                        {/foreach}
                    </select>
                    <select name="sc_id" id="site_city_2">
                        <option>楼栋</option>
                        {foreach item=c from=$sclist2}
                        <option value="{$c.sc_id}" {if $c.sc_id eq $site_city.sc_id} selected{/if}>{$c.title}</option>
                        {/foreach}
                    </select>
                    <input type="text" name="sushe" value="{$data.sushe}" placeholder="寝室号"><br>
                    
                </div>
            </div>

            <div class="comblock">
                寝室名称：<input type="text" name="title" value="{$data.title}" placeholder="起个很牛的名字吧">
<br><br>
            <button id="sushe_add" type="button" class="cart_change_btn">提交申请</button>

            </div>
            </form>
        </div>
    </div>
    
<script>
$(function(){
	$(document).on("change","#site_city_1",function(){
		$.get("/index.php?m=site_city&a=child&ajax=1&pid="+$(this).val(),function(data){
			var html='<option value="0">请选择</option>';
			if(data.error){
				$("#site_city_2").empty().append(html);
			}else{
				for(var i=0;i<data.data.length;i++){
					var html=html+'<option value="'+data.data[i].sc_id+'">'+data.data[i].title+'</option>';
				}
				$("#site_city_2").empty().append(html);
			}
		},"json"); 
	});
	
	$("#sushe_add").on("click",function(){
		$.post("/index.php?m=sushe&a=save&ajax=1",$("#sushe-form").serialize(),function(data){
			if(data.error){
				skyToast(data.message);
			}else{
				skyToast('保存成功');
			}
		},"json");
	});
		
});

</script>
 
</body>
</html>
